import { MenuItem, MenuTreeItem, MenuType } from "./models";
import req, { ResponseData } from "/@/api/req";

export const Api = {
  getMenuTreeData: "system/menu/treeselect",
  menu: "system/menu/",
  roleMenuTreeselect: "system/menu/roleMenuTreeselect/",
  getRouters: "getRouters",
};

export function getMenuTreeData() {
  return req.commonGet<MenuTreeItem[]>(
    Api.getMenuTreeData,
    {},
    {
      useGlobalLoading: false,
    }
  );
}

export function getRoleMenu(roleId: number) {
  return req.commonGetResponse(Api.roleMenuTreeselect + roleId, {}, { useGlobalLoading: false });
}

export function getMenuData() {
  return req.commonGet<MenuItem[]>(
    Api.getRouters,
    {},
    {
      useGlobalLoading: false,
    }
  );
}

export function getStaticMenuData() {
  return [
    {
      menuName: "文明服务",
      menuId: 0,
      path: "civilizedService",
      icon: "icon-shoufeizhan",
      menuType: MenuType.FEATURE,
      orderNum: 0,
      children: [
        {
          menuName: "收费站管理",
          path: "tollStationManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 1,
        },
        {
          menuName: "收费员管理",
          path: "tollCollectorManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 2,
        },
        {
          menuName: "设备管理",
          path: "deviceManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 3,
        },
      ],
    },
    {
      menuName: "系统管理",
      menuId: 4,
      path: "systemManage",
      icon: "icon-shoufeizhan",
      menuType: MenuType.FEATURE,
      orderNum: 0,
      children: [
        {
          menuName: "角色管理",
          path: "roleManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 6,
        },
        {
          menuName: "菜单管理",
          path: "menuManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 5,
        },
        {
          menuName: "用户管理",
          path: "userManage",
          icon: "icon-shoufeizhan",
          menuType: MenuType.FUNCTION,
          orderNum: 0,
          menuId: 7,
        },
      ],
    },
  ];
}
